home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / add-to-blacklist.xul < prev    next >
Extensible Markup Language  |  2010-01-15  |  3KB  |  94 lines

  1. <?xml version="1.0"?> 
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
  6.  
  7. <!DOCTYPE dialog SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  8.  
  9. <dialog id="dwhelper-dump-media"
  10.         title="&pref.title.blacklist;"
  11.         flex="1"
  12.         onload="onLoad()"
  13.         ondialogaccept="return doOk()"
  14.         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  15.         xmlns:html="http://www.w3.org/1999/xhtml"
  16.         buttonlabelextra2="&label.add2bl.configure-blacklist;"
  17.         ondialogextra2="configureBlacklist();"
  18.         buttons="accept,cancel,extra2">
  19.  
  20.     <html:style>
  21.  
  22. radiogroup {
  23.     margin-left: 15px;
  24. }
  25.     
  26.     </html:style>
  27.         
  28.     <script><![CDATA[
  29. var Util=Components.classes["@downloadhelper.net/util-service;1"]
  30.     .getService(Components.interfaces.dhIUtilService);
  31.  
  32. var simpleDomain=true;
  33. var blDomain;
  34.  
  35. function onLoad() {
  36.     var entry=window.arguments[0];
  37.     var url=Util.getPropsString(entry,"media-url");
  38.     var domain=/\/\/([^\/]+)\//.exec(url)[1];
  39.     if(/^([^\.]\.)?[^\.]$/.test(domain)) { // simple domain
  40.         document.getElementById("simple-domain").setAttribute("value",
  41.             Util.getFText("add2bl.label.add-domain",[domain],1));
  42.         document.getElementById("simple-domain").setAttribute("hidden","false");
  43.         blDomain=domain;
  44.     } else {
  45.         var parts=domain.split(".");
  46.         for(var i=0;i<parts.length-1;i++) {
  47.             var radio=document.createElement("radio");
  48.             var subdomain=parts.slice(i,parts.length).join(".");
  49.             radio.setAttribute("label",subdomain);
  50.             radio.setAttribute("value",subdomain);
  51.             radio.setAttribute("id",subdomain);
  52.             if(i==0)
  53.                 radio.setAttribute("selected","true");
  54.             document.getElementById("domains").appendChild(radio);
  55.         }
  56.         document.getElementById("domain-choice").setAttribute("hidden","false");
  57.         simpleDomain=false;
  58.     }
  59.     window.sizeToContent();
  60. }
  61.  
  62. function doOk() {
  63.     if(!simpleDomain) {
  64.         blDomain=document.getElementById("domains").selectedItem.getAttribute("value");
  65.     }
  66.     var prefService=Components.classes["@mozilla.org/preferences-service;1"]
  67.                                        .getService(Components.interfaces.nsIPrefService);
  68.     var pref=prefService.getBranch("dwhelper.");
  69.     var blPref=pref.getCharPref("media-host-blacklist");
  70.     var blacklist=blPref.split("|");
  71.     if(!(blDomain in blacklist)) {
  72.         blacklist.push(blDomain);
  73.         pref.setCharPref("media-host-blacklist",blacklist.join("|"));
  74.     }
  75.     return true;
  76. }
  77.  
  78. function configureBlacklist() {
  79.     var options="chrome,centerscreen,toolbar,modal";
  80.     var data={ selectedPanel: "panel-capture", selectedTab: "blacklisttab" }
  81.     window.openDialog("chrome://dwhelper/content/preferences-new.xul",'',options, data );    
  82. }
  83.  
  84. ]]>
  85.     </script>
  86.  
  87.     <label id="simple-domain" hidden="true"/>
  88.     <vbox flex="1" id="domain-choice" hidden="true">
  89.         <label value="&add2bl.label.add-domain-choice;"/>
  90.         <radiogroup id="domains"/>
  91.     </vbox>
  92.         
  93. </dialog>
  94.